package com.meta.nd.controller;



import com.meta.nd.vo.RequestMessage;
import com.meta.util.ExceptionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.meta.cache.NdCacheService;
import com.meta.nd.vo.Nd;
import com.meta.nd.vo.ReturnMessage;

@Slf4j
@RestController
public class NdController {
	
	@Autowired
	NdCacheService ndCacheService;
	@RequestMapping(value = "/nd/getNd", method = { RequestMethod.POST })
	public ReturnMessage<Nd> getRootNd(@RequestBody RequestMessage<String> requestMessage) {
		try {
			String ndCode = requestMessage.getValue();
			Nd nd = this.ndCacheService.getRootNd(ndCode);
			return  new ReturnMessage<Nd> (true,null,nd );
		
		}catch ( Exception e ) {
			log.error(e.getMessage(),e);
			return ExceptionUtils.buildReturnMessage(e);
		}
	}

}
